package com.smallcc.service.impl;

import com.smallcc.dataobject.ProductCategory;
import com.smallcc.dataobject.dao.ProductCategoryDao;
import com.smallcc.repository.ProductCategoryRepository;
import com.smallcc.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @author 晓风过境
 * @TODO
 * @date 2018/3/28 19:45
 * @day 28
 * @return $text$
 * @title ${CLASS_NAME}
 * @project_name sell
 */
@Service
public class CategoryServiceImpl implements CategoryService{
    @Autowired
    private ProductCategoryRepository repository;
//    @Autowired
//    private ProductCategoryDao productCategoryDao;
    @Override
    public Optional<ProductCategory> findOne(Integer categoryId) {
        return repository.findById(categoryId);
    }

    @Override
    public List<ProductCategory> findAll() {
        return repository.findAll();
    }

    @Override
    public List<ProductCategory> findByCategoryTypeIn(List<Integer> categoryTypeList) {
        return repository.findByCategoryTypeIn(categoryTypeList);
    }

    @Override
    public ProductCategory save(ProductCategory productCategory) {
        return repository.save(productCategory);
    }
}
